home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
jaz_clib.arc
/
JZGETPCE.C
< prev
next >
Wrap
Text File
|
1989-04-09
|
1KB
|
38 lines
/*
┌────────────────────────────────────────────────────────────────────────────┐
│jzgetpce.c │
│Return a delimited portion of a string. │
│ │
│Parms │
│ fsource : source string with delimiters │
│ fdestin : destin string to be returned │
│ fdel : char which is to be used as a delimiter │
│ fnum : which occurrance of the delimited string do you want? (base 1) │
│ │
└────────────────────────────────────────────────────────────────────────────┘
*/
char *jzgetpce(fsource , fdestin , fdel , fnum )
char *fsource , *fdestin , fdel;
int fnum;
{
char *p;
int w;
int wcount;
wcount = 1; /* search for specified piece */
while (*fsource && (wcount < fnum))
if (*fsource++ == fdel)
wcount ++;
if ((w = index(fsource,fdel)) != -1) { /* this is not the last piece */
strncpy(fdestin,fsource,w);
*(fdestin+w) = 0;
}
else
strcpy(fdestin,fsource);
return(fdestin);
}